Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void menu();
void menuChoice(int choice);
struct Player
{
char player_name[50];
int player_type;
double money;
struct Player *next;
}
int main(void) {
menu();
printf("Please enter a choice:");
system("cls");
int choice;
menuChoice(choice);
return 0;
}
void menu()
{
printf("Please choose one of the following:\n");
printf("Press 1 to start a new game.\n");
printf("Press 2 to load an existing game.\n");
printf("Press 3 to exit.\n");
}
void menuChoice(int choice)
{
scanf("%d", choice);
if(choice == 1)
{
struct Player *root;
root = malloc( sizeof(struct Player) );
root->next = 0;
int cpu_players;
printf("Choose a desired name:");
scanf("%s", &root->player_name);
printf("Choose an amount of money to play with: $");
scanf("%lf", &root->money);
root->player_type = 0 ;
printf("Please enter the number of CPU players: ");
scanf_s("%d", &cpu_players);
int i=0;
for(i=0;i<cpu_players;i++)
{
struct Player player;
player.player_type = 1;
printf("Choose a name for CPU player %d: ", i+1);
scanf("%s", player.player_name);
printf("Choose amount of money for cpu player %d: ", i+1);
scanf("%lf", &player.money);
}
}
else if(choice == 2)
{
}
else
{
exit(0);
}
}
So guys this is what I've written so far, there's an error that I can't get my head around in the main function
"16 C:\Dev-Cpp\main.c two or more data types in declaration of `main' "
Help much appreciated